// $Id: Configuration.cpp 25 2009-10-15 07:17:24Z skagget77 $

#include "PreCompile.h"
#include "TestModule/Configuration.h"
#include "TestModule/Ranger.h"
#include "TestModule/Shotgun.h"


namespace 
{
   Shotgun* ShotgunProvider( IoCpp::IContainerPtr container ) { 
      return new Shotgun(container->Inject<int>("Shotgun-Power"));
   }

   Ranger* RangerProvider( IWeapon* weapon ) { 
      return new Ranger(weapon);
   }
}


void Configuration( IoCpp::IContainerPtr container )
{
   IoCpp::Configuration conf(container);

   // Bind constant.
   conf.Bind<int>().ToConstant(49).WithName("Shotgun-Power");

   // Bind interfaces.
   conf.Bind<IWeapon*>().ToProvider(ShotgunProvider).WithName("Shotgun");
   conf.Bind<IWeapon*>().ToProvider(ShotgunProvider).WithName("AK-47");
   conf.Bind<IWeapon*>().ToProvider(ShotgunProvider).WithName("Assault Rifle").AsSingleton();

   conf.Bind<ISoldier*>().ToProvider(RangerProvider);
   conf.Bind<ISoldier*>().ToProvider(RangerProvider).WithName("Paratrooper");
   conf.Bind<ISoldier*>().ToProvider(RangerProvider).WithName("Infantry");
   conf.Bind<ISoldier*>().ToProvider(RangerProvider).WithName("Sniper");
}
